<template>
  <!-- 辅导员信息页面 -->
  <div class="app-container">
    <searchForm
      :formOptions="formOptions"
      @onSearch="onSearch"
      @onReset="onReset"
      :formLabelWidth="formLabelWidth"
      v-show="showSearch"
    />
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">辅导员信息</el-button>
      </el-col>
      <!-- 
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
      </el-col>-->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table :data="roleList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="教工号" prop="tno" align="center" :show-overflow-tooltip="true" />
      <el-table-column label="姓名" prop="thrName" :show-overflow-tooltip="true" align="center" />
      <el-table-column label="性别" prop="sex" :show-overflow-tooltip="true" align="center">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.sex" />
        </template>
      </el-table-column>
      <el-table-column label="任职院系" prop="deptName" align="center" :show-overflow-tooltip="true" />
      <!-- <el-table-column label="年级" prop="teacher.roleKey" align="center" />
      <el-table-column label="所在班级" prop="teacher.roleKey" align="center" />-->
      <el-table-column label="学历" prop="education" align="center">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.basic_education_type" :value="scope.row.education" />
        </template>
      </el-table-column>
      <el-table-column label="在岗状态" prop="postStatus" align="center">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.basic_post_status" :value="scope.row.postStatus" />
        </template>
      </el-table-column>
      <el-table-column label="任职类型" prop="officeType" align="center">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.bc_office_type" :value="scope.row.officeType" />
        </template>
      </el-table-column>
      <el-table-column label="联系电话" prop="phone" align="center" />
      <el-table-column label="是否辅导员" prop="isClr" align="center">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.clr_counsellor_type" :value="scope.row.isClr" />
        </template>
      </el-table-column>
      <el-table-column label="是否班主任" prop="isClassThr" align="center">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.clr_cthr_type" :value="scope.row.isClassThr" />
        </template>
      </el-table-column>
      <!-- <el-table-column label="岗位起始时间" prop="teacher.roleSort" align="center" />
      <el-table-column label="岗位截止时间" prop="teacher.roleSort" align="center" />-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:role:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:role:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改角色配置对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="60%"
      ppend-to-body
      @close="CloseIn"
      destroy-on-close
    >
      <!-- <el-form ref="form" :model="form" label-width="70px">
        <el-row>
          <el-col :span="10">
            <el-form-item label="教师信息" prop="tno">
              <el-autocomplete
                class="inputInfo"
                v-model="searchcursom"
                :fetch-suggestions="querySearch"
                :trigger-on-focus="false"
                style="width: 100%;"
                placeholder="请输入内容"
                @select="handleSelects"
              >
                <template slot-scope="{ item }">
                  <div class="name">姓名:{{ item.value }},工号:{{ item.address }}</div>
                </template>
              </el-autocomplete>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form> -->
      <el-form ref="form" :model="form" :rules="rules" label-width="95px">
            <el-row>
              <el-col :span="8">
                <el-form-item label="所属院系" prop="deptId">
                  <el-cascader
                    v-model="form.deptId"
                    :options="deptOptions"
                    :props="{ value: 'id',currentLabels: 'label',checkStrictly: true }"
                    style="width: 100%"
                    @change="handleChange"
                    clearable
                  ></el-cascader>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="来校日期" prop="admissionTime">
                  <el-date-picker
                    v-model="form.admissionTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择来校日期"
                    style="width: 100%"
                  ></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="工号" prop="tno">
                  <el-input v-model.trim="form.tno" clearable placeholder="请输入工号" maxlength="30" />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="姓名" prop="name">
                  <el-input v-model.trim="form.name" clearable placeholder="请输入姓名" maxlength="10" />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="性别" prop="sex">
                  <el-select v-model="form.sex" clearable placeholder="请选择性别" style="width: 100%">
                    <el-option
                      v-for="dict in dict.type.sys_user_sex"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="在职状态" prop="postStatus">
                  <el-select v-model="form.postStatus" clearable placeholder="请选择在职状态" style="width: 100%">
                    <el-option
                      v-for="dict in dict.type.basic_post_status"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="血型" prop="bloodType">
                  <el-select
                    clearable
                    v-model="form.bloodType"
                    placeholder="请选择血型"
                    style="width: 100%"
                  >
                    <el-option
                      v-for="dict in dict.type.basic_blood_type"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="身份证件号" prop="cardCode">
                  <el-input
                    v-model.trim="form.cardCode"
                    placeholder="请输入身份证件号"
                    clearable
                    maxlength="18"
                    @blur="codeBulr"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="出生日期" prop="birthday">
                  <el-date-picker
                    v-model="form.birthday"
                    disabled
                    type="date"
                    placeholder="选择出生日期"
                    style="width: 100%"
                    value-format="yyyy-MM-dd"
                    format="yyyy-MM-dd"
                  ></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="联系方式" prop="phone">
                  <el-input v-model.trim="form.phone" placeholder="请输入联系方式" maxlength="11"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="民族" prop="nation">
                  <el-select v-model="form.nation" placeholder="请选择民族" style="width: 100%">
                    <el-option
                      v-for="dict in dict.type.bc_nation_type"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="政治面貌" prop="political">
                  <el-select v-model="form.political" placeholder="请选择政治面貌" style="width: 100%">
                    <el-option
                      v-for="dict in dict.type.bc_political_type"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="曾用名" prop="formerName">
                  <el-input v-model.trim="form.formerName" placeholder="请输入曾用名" maxlength="10" />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="籍贯" prop="bnpId">
                  <el-input v-model.trim="form.bnpId" placeholder="请输入籍贯" maxlength="30" />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="学历" prop="education">
                  <el-select v-model="form.education" placeholder="请选择学历" style="width: 100%">
                    <el-option
                      v-for="dict in dict.type.basic_education_type"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="学位" prop="acDegree">
                  <el-select v-model="form.acDegree" placeholder="请选择学位" style="width: 100%">
                    <el-option
                      v-for="dict in dict.type.basic_degree_type"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
             
              <el-col :span="8">
                <el-form-item label="职称" prop="title">
                  <el-select v-model="form.title" placeholder="请选择职称" style="width: 100%">
                    <el-option
                      v-for="dict in dict.type.basic_title_type"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="职称级别" prop="titleLevel">
                  <el-select v-model="form.titleLevel" placeholder="请选择职称级别" style="width: 100%">
                    <el-option
                      v-for="dict in dict.type.basic_title_level"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
             
              
            </el-row>
          </el-form>
      <!-- <el-table
        :data="dataList"
        @selection-change="teacherSelectionChange"
        v-loading="loading"
        style="margin-bottom: 20px;"
      >
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="工号" prop="tno" :show-overflow-tooltip="true" align="center" />
        <el-table-column label="姓名" prop="name" align="center">
          <template slot-scope="scope">{{ scope.row.name || scope.row.thrName }}</template>
        </el-table-column>
        <el-table-column label="单位名称" :show-overflow-tooltip="true" prop="deptNames" align="center">
          <template slot-scope="scope">{{ scope.row.deptNames || scope.row.deptName }}</template>
        </el-table-column>
        <el-table-column label="性别" prop="sex" align="center">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.sex" />
          </template>
        </el-table-column>
        <el-table-column label="学历" prop="education" align="center">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.basic_education_type" :value="scope.row.education" />
          </template>
        </el-table-column>
      </el-table> -->
      <h2>工作经历</h2>
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="primary"
            icon="el-icon-plus"
            size="mini"
            @click="handleAddClrWorkHistory"
          >添加</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="danger"
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDeleteClrWorkHistory"
          >删除</el-button>
        </el-col>
      </el-row>
      <el-table
        :data="clrWorkHistoryList"
        @selection-change="handleClrWorkHistorySelectionChange"
        ref="clrWorkHistory"
      >
        <el-table-column type="selection" width="50" align="center" />
        <el-table-column label="序号" align="center" type="index" width="50" />
        <el-table-column label="公司名称" prop="cName" align="center"></el-table-column>
        <el-table-column label="开始时间" prop="startDate" align="center"></el-table-column>
        <el-table-column label="结束时间" prop="endDate" align="center"></el-table-column>
        <el-table-column label="职位名称" prop="jobTitle" align="center"></el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="workDetails(scope.row)"
              v-hasPermi="['system:role:details']"
            >查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-dialog
        width="50%"
        title="工作经历"
        :visible.sync="innerVisible"
        append-to-body
        destroy-on-close
      >
        <el-form ref="formWork" :model="formWork" :rules="workRules" label-width="90px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="公司名称" prop="cName">
                <el-input v-model="formWork.cName" placeholder="请输入公司名称" maxlength="30" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="职位名称" prop="jobTitle">
                <el-input v-model="formWork.jobTitle" placeholder="请输入职位名称" maxlength="30" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="起止时间">
                <el-date-picker
                  v-model="dataTime"
                  type="daterange"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  @change="dateTimes"
                  value-format="yyyy-MM-dd"
                ></el-date-picker>
              </el-form-item>
            </el-col>

            <el-col :span="24">
              <el-form-item label="工作内容" prop="workContent">
                <editor v-model="formWork.workContent" :min-height="180" />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="工作业绩" prop="workPerformance">
                <editor v-model="formWork.workPerformance" :min-height="180" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitWork" :disabled="workDisabled">确 定</el-button>
          <el-button @click="innerVisible = false">取 消</el-button>
        </div>
      </el-dialog>
      <h2>教育背景</h2>
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="primary"
            icon="el-icon-plus"
            size="mini"
            @click="educationalAdd"
          >添加</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="danger"
            icon="el-icon-delete"
            size="mini"
            :disabled="multipleEducation"
            @click="handleDeleteClrEducationHistory"
          >删除</el-button>
        </el-col>
      </el-row>
      <!-- <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="educationalVisible = true">新增</el-button> -->
      <el-table :data="clrEducationList" @selection-change="handleClrEducationSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="学历" prop="education" align="center" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.basic_education_type" :value="scope.row.education" />
          </template>
        </el-table-column>
        <el-table-column label="毕业学校" prop="sName" :show-overflow-tooltip="true" align="center" />
        <el-table-column label="毕业专业" prop="gMajor" :show-overflow-tooltip="true" align="center" />
        <el-table-column label="学习方式" prop="lStyle" :show-overflow-tooltip="true" align="center">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.clr_learning_style" :value="scope.row.lStyle" />
          </template>
        </el-table-column>
        <el-table-column label="学制" prop="eSystem" :show-overflow-tooltip="true" align="center">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.bc_speciality_type" :value="scope.row.eSystem" />
          </template>
        </el-table-column>
        <el-table-column label="毕业时间" prop="endDate" align="center" :show-overflow-tooltip="true" />
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="educationDetails(scope.row)"
              v-hasPermi="['system:role:details']"
            >查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-dialog
        width="50%"
        title="教育背景"
        :visible.sync="educationalVisible"
        append-to-body
        destroy-on-close
      >
        <el-form
          ref="educationFrom"
          :model="educationFrom"
          :rules="educationRole"
          label-width="90px"
        >
          <el-row>
            <el-col :span="12">
              <el-form-item label="学历" prop="education">
                <el-select v-model="educationFrom.education" placeholder="请选择" style="width: 100%">
                  <el-option
                    v-for="dict in dict.type.basic_education_type"
                    :key="dict.index"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="毕业学校" prop="sName">
                <el-input v-model="educationFrom.sName" placeholder="请输入毕业学校" maxlength="30" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学校类型" prop="sType">
                <el-select v-model="educationFrom.sType" placeholder="请选择" style="width: 100%">
                  <el-option
                    v-for="dict in dict.type.clr_school_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="授予国家" prop="educationCountry">
                <el-select
                  v-model="educationFrom.educationCountry"
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="dict in dict.type.basic_stu_duties"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="入校时间" prop="startDate">
                <el-date-picker
                  v-model="educationFrom.startDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="毕业时间" prop="endDate">
                <el-date-picker
                  v-model="educationFrom.endDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学科" prop="discipline">
                <el-input v-model="educationFrom.discipline" placeholder="请输入学科" maxlength="30" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="毕业专业" prop="gMajor">
                <el-input v-model="educationFrom.gMajor" placeholder="请输入毕业专业" maxlength="30" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学习形式" prop="lModality">
                <el-select v-model="educationFrom.lModality" placeholder="请选择" style="width: 100%">
                  <el-option
                    v-for="dict in dict.type.clr_learning_forms"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学习方式" prop="lStyle">
                <el-select v-model="educationFrom.lStyle" placeholder="请选择" style="width: 100%">
                  <el-option
                    v-for="dict in dict.type.clr_learning_style"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学制" prop="eSystem">
                <el-select v-model="educationFrom.eSystem" placeholder="请选择" style="width: 100%">
                  <el-option
                    v-for="dict in dict.type.bc_speciality_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="是否最高学历" prop="isEducation">
                <el-select
                  v-model="educationFrom.isEducation"
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="dict in dict.type.sys_yes_no"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位" prop="aDegree">
                <el-input v-model="educationFrom.aDegree" placeholder="请输入学习形式" maxlength="30" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位类型" prop="degreeType">
                <el-select v-model="educationFrom.degreeType" placeholder="请选择" style="width: 100%">
                  <el-option
                    v-for="dict in dict.type.basic_degree_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位授予国家" prop="degreeCountry">
                <el-select
                  v-model="educationFrom.degreeCountry"
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="dict in dict.type.basic_stu_duties"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位授予单位" prop="degreeUnit">
                <el-input
                  v-model="educationFrom.degreeUnit"
                  placeholder="请输入学位授予单位"
                  maxlength="30"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位授予日期" prop="degreeDate">
                <el-date-picker
                  v-model="educationFrom.degreeDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="是否最高学位" prop="isDegree">
                <el-select v-model="educationFrom.isDegree" placeholder="请选择" style="width: 100%">
                  <el-option
                    v-for="dict in dict.type.sys_yes_no"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位专业" prop="degreeMajor">
                <el-input v-model="educationFrom.degreeMajor" placeholder="请输入学位专业" maxlength="30" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitEducation" :disabled="educationDisabled">确 定</el-button>
          <el-button @click="educationalCancel">取 消</el-button>
        </div>
      </el-dialog>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { deptTreeSelect } from "@/api/system/user";
import {
  counsellorList,
  unabsorbedList,
  counsellor,
  delCounsellor,
  counsellorInfor,
  updataCounsellor
} from "@/api/counselor/index";
import searchForm from "@/components/Search/searchForm.vue";
import { getDicts } from "@/api/system/dict/type";

export default {
  name: "Role",
  dicts: [
    "basic_education_type", // 学历类型
    "basic_degree_type", // 学位类型
    "sys_user_sex", // 性别
    "bc_political_type", // 政治面貌
    "bc_nation_type", // 民族类型
    "clr_counsellor_type", // 是否辅导员
    "clr_cthr_type", // 是否班主任
    "bc_office_type", // 任职类型
    "basic_post_status", //在岗状态
    "clr_learning_style", //学习方式
    "clr_learning_forms", //学习形式
    "clr_school_type", //学校类型
    "sys_yes_no", //学位类型
    "basic_blood_type", // 血型
    "basic_title_type", // 职称类型
    "basic_title_level", // 职称级别
    "bc_speciality_type" //学制类型
  ],
  components: { searchForm },

  data() {
    return {
      formLabelWidth: "85px",
      formOptions: [
        {
          label: "教工号",
          prop: "tno",
          element: "el-input",
          placeholder: "请输入教工号"
        },
        {
          label: "姓名",
          prop: "thrName",
          element: "el-input",
          placeholder: "请输入姓名"
        },
        {
          label: "任职类型",
          prop: "officeType",
          element: "el-select",
          options: [],
          placeholder: "请选择任职类型"
        },
        {
          label: "是否辅导员",
          prop: "isClr",
          element: "el-select",
          options: [],
          placeholder: "请选择是否辅导员"
        },
        {
          label: "是否班主任",
          prop: "isClassThr",
          element: "el-select",
          options: [],
          placeholder: "请选择是否班主任"
        }
      ],
      educationFrom: {
        sName: ""
      }, // 教育背景参数
      clrEducationList: [], //
      formWork: {},
      clrWorkHistoryList: [],
      educationSname: [],
      dataTime: [],
      workDisabled: false,
      educationDisabled: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      multipleEducation: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 角色表格数据
      roleList: [],
      dataList: [], // 获取教师信息列表数据
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 是否显示弹出层（数据权限）
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        roleName: undefined,
        roleKey: undefined,
        status: undefined
      },
      // 表单参数
      form: {
        tno: ""
      },
      formTeacher: {
        isClassThr: "",
        isClr: ""
      },
      defaultProps: {
        children: "children",
        label: "label"
      },
      workCname: [],
      innerVisible: false, // 添加工作经历弹窗
      educationalVisible: false, // 教育背景弹窗
      // 表单校验
      rules: {
        isClr: [
          { required: true, message: "请选择是否辅导员", trigger: "change" }
        ],
        isClassThr: [
          { required: true, message: "请选择是否班主任", trigger: "change" }
        ]
      },
      workRules: {
        cName: [
          { required: true, message: "请输入公司名称", trigger: "bulr" }
        ],
        jobTitle: [
          { required: true, message: "请输入职务名称", trigger: "bulr" }
        ],
        startDate: [
          { required: true, message: "请选择时间", trigger: "change" }
        ],
        endDate: [
          { required: true, message: "请选择时间", trigger: "change" }
        ],
      },
      educationRole: {
        education: [
          { required: true, message: "请选择学历", trigger: "change" }
        ],
        sName: [{ required: true, message: "请输入毕业学校", trigger: "bulr" }],
        gMajor: [
          { required: true, message: "请输入毕业专业", trigger: "bulr" }
        ],
        startDate: [
          { required: true, message: "请选择入校时间", trigger: "change" }
        ],
        endDate: [
          { required: true, message: "请选择毕业时间", trigger: "change" }
        ],
        lStyle: [
          { required: true, message: "请选择学习方式", trigger: "change" }
        ],
        eSystem: [{ required: true, message: "请选择学制", trigger: "change" }]
      },
      restaurants: [],
      teacherListAll: [],
      menus: [],
      subMenuList: [],
      openKeys: [],
      selectedKeys: [],
      markDownTxt: "",
      searchcursom: "",
      helpList: [],
      deptOptions:[]
    };
  },
  async created() {
    console.log("this.$store.state.user.name",this.$store.state.user.userInfor)
    this.getList();
    getDicts("clr_counsellor_type").then(res => {
      this.formOptions[3].options = res.data.map(item => {
        return {
          value: item["dictValue"],
          label: item["dictLabel"]
        };
      });
    });
    getDicts("clr_cthr_type").then(res => {
      this.formOptions[4].options = res.data.map(item => {
        return {
          value: item["dictValue"],
          label: item["dictLabel"]
        };
      });
    });
    getDicts("bc_office_type").then(res => {
      this.formOptions[2].options = res.data.map(item => {
        return {
          value: item["dictValue"],
          label: item["dictLabel"]
        };
      });
    });
  },
  mounted() {
    // console.log(this.restaurants, "this");
  },
  methods: {
     // 获取部门信息
     async department() {
      await deptTreeSelect().then(res => {
        this.deptOptions = res.data;
      });
    },
    handleChange(value) {
      if (value) {
        this.form.deptId = value[value.length - 1];
      }
      // this.form.deptId = value[2];
      // this.form.multistage = value + "";
    },
     // 根据身份证号获取出生年月
     codeBulr() {
      if(this.form.cardCode){
        this.$set(this.form, "birthday", this.getBirthday(this.form.cardCode));
      }
    },
    handleSelect() {
      unabsorbedList({ tno:this.$store.state.user.name}).then(res => {
        console.log(res, "教师信息列表");
        this.dataList = res.rows;
      });
    },
    querySearch(queryString, cb) {
      if (queryString == "") return; //如果输入框无内容，不调接口
      unabsorbedList({ name: queryString }).then(res => {
        if (res && res.code == 200) {
          //传关键字后返回的结果就是筛选后的
          this.helpList = res.rows.map(item => {
            return {
              value: item["name"],
              address: item["tno"]
            };
          });
          var helpList = this.helpList;
          var results = queryString
            ? helpList.filter(this.createFilter(queryString))
            : helpList;
          // 调用 callback 返回建议列表的数据
          cb(results);
        }
      });
    },
    createFilter(queryString) {
      return item => {
        return (
          item.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
        );
      }; //fVcHelpCenterName是接口返回的名称和输入的名称做对比
    },
    // 添加工作经历
    handleAddClrWorkHistory() {
      this.innerVisible = true;
      this.workDisabled = false
      this.formWork = {}
    },
    // 添加教育背景
    educationalAdd() {
      this.educationalVisible = true
      this.educationDisabled = false
      this.educationFrom = {}
    },
    // 起止时间
    dateTimes() {
      console.log(this.dataTime, "dateTime");
      this.formWork.startDate = this.dataTime[0];
      this.formWork.endDate = this.dataTime[1];
    },
    // 工作经历
    submitWork() {
      console.log(this.dataTime, "submitWork");
      if(this.dataTime.length == 0){
        this.$modal.msgWarning("请选择时间");
      }else {
        if (this.clrWorkHistoryList.length > 0) {
        this.clrWorkHistoryList.forEach(element => {
          if (element.cName == this.formWork.cName) {
            this.$modal.msgWarning("添加的工作单位已存在");
          } else {
            this.$refs["formWork"].validate(valid => {
              if (valid) {
                this.clrWorkHistoryList = this.clrWorkHistoryList;
                this.clrWorkHistoryList.push(this.formWork);
                this.dataTime = [];
                this.formWork = {};
                this.innerVisible = false;
              }
            });
          }
        });
      } else {
        this.$refs["formWork"].validate(valid => {
          if (valid) {
            this.clrWorkHistoryList = this.clrWorkHistoryList;
            this.clrWorkHistoryList.push(this.formWork);
            this.dataTime = [];
            this.formWork = {};
            this.innerVisible = false;
          }
        });
      }
      }
      
    },
    // 删除工作经历
    handleDeleteClrWorkHistory() {
      this.clrWorkHistoryList = this.clrWorkHistoryList.filter(
        item => !this.workCname.some(it => it.cName === item.cName)
      );
    },
    // 删除教育背景
    handleDeleteClrEducationHistory() {
      this.clrEducationList = this.educationSname.filter(
        item => !this.educationSname.some(it => it.sName === item.sName)
      );
    },
    // 教育背景查看详情
    educationDetails(row) {
      this.educationFrom = row
      
      this.educationalVisible = true
      this.educationDisabled = true
    },
    // 工作经历查看详情
    workDetails(row) {
      this.dataTime = []
      this.formWork = row
      this.dataTime.push(row.startDate,row.endDate)
      this.innerVisible = true
      this.workDisabled = true
    },
    // 工作经历多选
    handleClrWorkHistorySelectionChange(selection) {
      this.workCname = selection;
      this.multiple = !selection.length;
    },
    // 教育背景多选
    handleClrEducationSelectionChange(selection) {
      this.educationSname = selection;
      this.multipleEducation = !selection.length;
    },
    // 教育背景参数添加
    submitEducation() {
    
      if (this.clrEducationList.length > 0) {
        this.clrEducationList.forEach(element => {
          if (element.sName == this.educationFrom.sName) {
            this.$modal.msgWarning("添加的学校已存在");
          } else {
            this.$refs["educationFrom"].validate(valid => {
              if (valid) {
                this.clrEducationList = this.clrEducationList;
                this.clrEducationList.push(this.educationFrom);
                this.educationalVisible = false;
                this.educationFrom = {};
              } else {
              }
            });
          }
        });
      } else {
        this.$refs["educationFrom"].validate(valid => {
          if (valid) {
            this.clrEducationList = this.clrEducationList;
            console.log(this.educationFrom, "push");
            this.clrEducationList.push(this.educationFrom);
            console.log(this.clrEducationList, "添加");

            this.educationalVisible = false;
            this.educationFrom = {};
          } else {
          }
        });
      }
    },
    // 弹窗取消
    educationalCancel() {
      this.educationalVisible = false;
      this.resetForm("educationFrom");
    },
    // 清除表单
    CloseIn() {
      this.form = {};
      this.formTeacher = {};
      this.open = false;
    },
    // 选择未分配教师信息
    teacherSelectionChange(data) {
      if (data.length > 0) {
        this.formTeacher.tId = data[0].id;
      }
      console.log(data, "教师信息未分配");
    },
    // 获取搜索表单提交的数据
    onSearch(val) {
      // 查询条件和分页数据合并
      this.queryParams = Object.assign(this.queryParams, val);
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // 重置
    onReset(data) {
      console.log(data);
      this.queryParams.pageNum = 1;
      this.queryParams = Object.assign(this.queryParams, data);
      console.log(this.queryParams);
      this.getList();
    },
    /** 查询角色列表 */
    getList() {
      this.loading = true;
      counsellorList(this.queryParams).then(response => {
        this.roleList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;

      this.$refs.forms.clearValidate();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.roleId);
      this.single = selection.length != 1;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.department()
      this.handleSelect()
      this.dataList = [];
      this.clrWorkHistoryList = [];
      this.clrEducationList = [];
      this.form = {};
      this.formTeacher = {};
      this.open = true;
      this.title = "添加辅导员信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.dataList = [];
      this.formTeacher = {
        isClassThr: undefined,
        isClr: undefined
      };
      const roleId = row.cId || this.ids;
      // this.formTeacher
      counsellorInfor(roleId).then(response => {
        // this.form = response.data;
        this.open = true;
        this.dataList.push(response.data);
        this.formTeacher.isClassThr = response.data.isClassThr;
        this.formTeacher.isClr = response.data.isClr;
        this.formTeacher.tId = response.data.tId;
        this.formTeacher.cId = response.data.cId;
        this.clrWorkHistoryList = response.data.clrWorkHistoryList;
        this.clrEducationList = response.data.clrEducationList;
        console.log(this.dataList, "dataList");

        this.title = "修改辅导员信息";
      });
    },
    /** 提交按钮 */
    submitForm: function() {
      this.formTeacher.clrWorkHistoryList = this.clrWorkHistoryList;
      this.formTeacher.clrEducationList = this.clrEducationList;
      if (this.formTeacher.tId) {
        this.$refs["forms"].validate(valid => {
          if (valid) {
            if (this.formTeacher.cId) {
              updataCounsellor(this.formTeacher).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.form = {};
                this.formTeacher = {};
                this.open = false;
                this.getList();
              });
            } else {
              counsellor(this.formTeacher).then(response => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.form = {};
                this.formTeacher = {};
                this.getList();
              });
            }
          }
        });
      } else {
        this.$modal.msgWarning("请选中修改的教师信息");
      }
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const roleIds = row.cId || this.ids;
      this.$modal
        .confirm('是否确认删除角色编号为"' + roleIds + '"的数据项？')
        .then(function() {
          return delCounsellor(roleIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "system/role/export",
        {
          ...this.queryParams
        },
        `role_${new Date().getTime()}.xlsx`
      );
    }
  }
};
</script>